Advent of Cyber día 3

Objetivos:

Herramientas y conocimientos usados:


Comienzo

Algo importante que debemos tener en consideración antes de comenzar:
Nada es perfecto, incluyendo la detección. Por lo tanto debemos siempre apuntar a hacer más pequeñas estas brechas de seguridad.
Las brechas son muchas veces por las siguientes razones:

Cyber Kill Chain

La cyber kill chain es un modelo desarrollado por Lockheed Martin que muestra las distintas etapas típicas de un ataque cibernético, está basado en conceptos militares pero se ha adaptado a la ciberseguridad.

Tabla con las etapas, descripción, ejemplos y acciones que puede tomar la defensa para mitigar.

Stage Description Common Examples Defender Actions
Reconnaissance Gathering target information - Network scanning
- Social media research
- Email harvesting
- OSINT gathering
- Limit public information
- Hide network details
- Monitor for scanning activities
Weaponization Creating attack tools - Malware development
- Exploit modification
- Payload packaging
- Keep systems patched
- Monitor threat intelligence
- Study common attack tools
Delivery Getting weapons to target - Phishing emails
- Malicious websites
- USB drops
- Drive-by downloads
- Email filtering
- Web filtering
- USB disable policies
- User training
Exploitation Breaking into the system - Software vulnerabilities
- Zero-day exploits
- Social engineering
- Regular patching
- Security updates
- Endpoint protection
- Access controls
Installation Establishing persistence - Malware installation
- Backdoor creation
- Registry modifications
- Application whitelisting
- Behavior monitoring
- File integrity monitoring
Command & Control Setting up remote control - Hidden communication channels
- Covert protocols
- Remote access tools
- Network monitoring
- Traffic analysis
- Firewall rules
- IDS/IPS systems
Actions on Objectives Achieving attack goals - Data theft
- Ransomware deployment
- System destruction
- Further lateral movement
- Data encryption
- Backup systems
- Access logging
- Incident response plans

MITRE ATT&CK

MITRE ATT&CK (Adversarial Tactics, Techniques, and Common Knowledge), es un framework utilizado para entender las distintas técnicas y tácticas que los actores de amenaza realizan.
Es una recolección de tácticas, técnicas y procedimientos que han sido implementadas en la realidad, de este modo podemos entenderlas mejor.
Si bien es sólo una explicación teórica, es importante de comprender.


Atomic Red

Atomic Red Team es una biblioteca de casos de prueba que están mapeados al ATT&CK. Son casos sencillos que pueden ser ejecutados para detectar brechas de seguridad y cerrarlas. Además soporta automatización para ejecutar pruebas periódicas de forma automática.

Parametro Explicación Ejemplo
-Atomic Technique Define la técnica a emular. Podemos usar el nombre completo o el valor "TXXXX". Se puede omitir Invoke-AtomicTest -AtomicTechnique T1566.001
-ShowDetails Muestra los detalles de cada prueba incluída Invoke-AtomicTest T1566.001 -ShowDetails
-ShowDetailsBrief Muestra el título de cada prueba incluída Invoke-AtomicTest T1566.001 -ShowDetailsBrief
-CheckPrereqs Revisa si todo los componentes necesarios están presentes para la prueba Invoke-AtomicTest T1566.001 -CheckPrereqs
-TestNames Setea las pruebas que quieres ejecutar, usando el nombre completo Invoke-AtomicTest T1566.001 -TestNames "Download Macro-Enabled Phishing Attachment"
-TestGuids Setea las pruebas que quieres ejecutar usando el identificador Invoke-AtomicTest T1566.001 -TestGuids 114ccff9-ae6d-4547-9ead-4cd69f687306
-TestNumbers Setea las pruebas que quieres ejecutar usando el número de prueba. Limitado a la técnica atómica Invoke-AtomicTest T1566.001 -TestNumbers 2,3
-Cleanup Ejecuta los comandos de limpieza que fueron configurados previamente para revertir el estado de la máquina a normal. Invoke-AtomicTest T1566.001 -TestNumbers 2 -Cleanup
Vamos a ejecutar T1566.001 con Atomic.

T1566.001

Si buscamos T1566.001 en el sitio de MITRE, nos encontramos con lo siguiente:

Básicamente podemos entender que es un tipo de Spearphishing con un adjunto.
Esto también podemos verlo ejecutando el comando Invoke-AtomicTest T1566.001 -ShowDetails

La información que nos entrega este comando es:

Primero debemos revisar si están los recursos necesarios: Invoke-AtomicTest T1566.001 -TestNumbers 1 -CheckPrereq

Ahora ejecutamos el comando:
Invoke-AtomicTest T1566.001 -TestNumber 1


Se ha ejecutado con éxito.
Ahora deberíamos revisar a través del System Monitor (de Windows) lo que ha ocurrido.
Primero correremos el cleanup de Atomic Invoke-AtomicTest T1566.001 -TestNumbers 1 -cleanup

Y nos iremos al Sysmon:

  1. Event Viewer
  2. Apllications and Services
  3. Microsoft
  4. Windows
  5. Sysmon
  6. Operational

Podemos ver ahí en el tercer evento la siguiente información:

Con esta información podemos crear reglas de alerta.

Alertas

Hay distintos formatos de alerta incluyendo Yara, Sigma, Snort, etc.
Gracias a la información obtenida, podemos crear reglas en sigma.
Tenemos por ejemplo detalles importantes como WebRequest, la url y el nombre del archivo descargado.

title: Detect PowerShell Invoke-WebRequest and File Creation of PhishingAttachment.xlsm
	id: 1
	description: Detects the usage of Invoke-WebRequest to download PhishingAttachment.xlsm and the creation of the file
PhishingAttachment.xlsm.
	status: experimental
	author: TryHackMe
	logsource:
		category: process_creation
		product: windows
		service: sysmon
	detection:
		selection_invoke_webrequest:
			EventID: 1
			CommandLine|contains:
				- 'Invoke-WebRequest'
				-'http://localhost/PhishingAttachment.xlsm' 
				
			selection_file_creation:
			EventID: 11 # Sysmon Event ID for File Creation
			TargetFilename|endswith: '\PhishingAttachment.xlsm'
			
			condition: selection_invoke_webrequest or selection_file_creation
			falsepositives:
			- Legitimate administration activity may use Invoke-WebRequest, and legitimate Excel files may be created with similar names.
			level: high
			tags:
			- attack.t1071.001 # Web Service - Application Layer Protocol
			- attack.t1059.001 # PowerShell
			- attack.t1105 # Ingress Tool Transfer 
			- attack.t1566.001 # Spearphishing Attachment

En la parte de detection es donde ocurre la detección. Esta regla podemos importarla a nuestro sistema de detección.

Correremos un segundo ataque donde se realice un ransomware a través del shell


Preguntas

Con esto hemos completado el día 4

Por cierto... la bandera la podemos ingresar en Cyberchef y nos entrega un mensajito acerca de nuestro personaje glitch.

Procedemos al Advent of Cyber día 5